# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('libevent' 'libevent-devel')
pkgver=2.1.11
pkgrel=1
pkgdesc="An event notification library"
arch=('i686' 'x86_64')
url="https://libevent.org/"
license=('BSD')
makedepends=('openssl-devel')
source=("https://github.com/${pkgname}/${pkgname}/releases/download/release-${pkgver}-stable/${pkgname}-${pkgver}-stable.tar.gz"{,.asc})
sha256sums=('a65bac6202ea8c5609fd5c7e480e6d25de467ea1917c08290c521752f147283d'
            'SKIP')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}-stable
  ./autogen.sh
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}-stable
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --disable-libevent-regress
  make
  make DESTDIR="$srcdir/dest" install
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}-stable
  make -k check
}

package_libevent() {
  depends=('openssl')
  optdepends=('python2: to use event_rpcgen.py')

  mkdir -p $pkgdir/usr/bin
  cp -rf $srcdir/dest/usr/bin $pkgdir/usr/
  install -Dm644 $srcdir/${pkgname}-${pkgver}-stable/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_libevent-devel() {
  pkgdesc="Libevent headers and libraries"
  groups=('development')
  depends=("libevent=${pkgver}" "openssl-devel")

  mkdir -p $pkgdir/usr
  cp -rf $srcdir/dest/usr/include $pkgdir/usr/
  cp -rf $srcdir/dest/usr/lib $pkgdir/usr/
}
